package test.utils;

import basemod.ReflectionHacks;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.helpers.FontHelper;

public class FontUtils {
    public static BitmapFont createFont(float size, int shadowOffsetX, int shadowOffsetY, Color shadowColor,  boolean isLinearFiltering) {
        FreeTypeFontGenerator.FreeTypeFontParameter param= ReflectionHacks.getPrivateStatic(FontHelper.class,"param");
        FreeTypeFontGenerator.FreeTypeFontParameter originalParam =  param;

        param = new FreeTypeFontGenerator.FreeTypeFontParameter();
        param.shadowColor = shadowColor;
        param.shadowOffsetX = shadowOffsetX;
        param.shadowOffsetY = shadowOffsetY;
        param.size = Math.round(size * Settings.scale);

        ReflectionHacks.setPrivateStatic(FontHelper.class,"param", param);
        BitmapFont font = FontHelper.prepFont(size, isLinearFiltering);

        ReflectionHacks.setPrivateStatic(FontHelper.class,"param", originalParam);

        return font;
    }

    public static BitmapFont createNoShadowFont(float size){
        return createFont(size,0,0,new Color(0.0f,0.0f,0.0f,0.0f),false);
    }

}
